<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTML5其他功能</title>
<style>
	textarea{ width:300px; height:100px; }
</style>
</head>
<body>
	标题 : <input type="text"> <br>
 	性别 : <input type="radio" value="男">男
 	      <input type="radio" value="女">女
 	 	<br>
 	内容 : <textarea id="t1"></textarea>
</body>
<script>
var aInput = document.getElementsByTagName('input');
 	var oT = document.getElementById('t1');
if(window.localStorage.getItem('title')){
	aInput[0].value = window.localStorage.getItem('title');
}
	for(var i=1;i<aInput.length;i++){
		if( aInput[i].value == window.localStorage.getItem('sex') ){
 		aInput[i].checked = true;
	}
	}
if(window.localStorage.getItem('text')){
		oT.value = window.localStorage.getItem('text');
}
	window.onunload = function(){
 		if( aInput[0].value ){
			window.localStorage.setItem('title',aInput[0].value);
	}
		for(var i=1;i<aInput.length;i++){
			if( aInput[i].checked ){
				window.localStorage.setItem('sex',aInput[i].value);
		}
	}
	if( oT.value ){
			window.localStorage.setItem('text',oT.value);
	}	
};
 </script>
